package com.platform.module.common.redis;

import com.platform.module.common.redis.lock.DistributedLock;
import com.platform.module.common.redis.lock.RedisDistributedLock;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;

@Configuration
@AutoConfigureAfter({RedisConfig.class})
public class DistributedLockAutoConfiguration {
    @Bean
    @ConditionalOnBean({RedisTemplate.class})
    public DistributedLock redisDistributedLock(RedisTemplate<String, Object> redisTemplate) {
        return new RedisDistributedLock(redisTemplate);
    }
}
